@extends('layouts.layouts')
@section('title')
    <title>后台首页</title>
    <style>
        .file {
            position: relative;
            display: inline-block;
            background: #D0EEFF;
            border: 1px solid #99D3F5;
            border-radius: 4px;
            padding: 4px 12px;
            overflow: hidden;
            color: #1E88C7;
            text-decoration: none;
            text-indent: 0;
            line-height: 20px;
        }
        .file input {
            position: absolute;
            font-size: 100px;
            right: 0;
            top: 0;
            opacity: 0;
        }
        .file:hover {
            background: #AADFFD;
            border-color: #78C3F3;
            color: #004974;
            text-decoration: none;
        }
    </style>
@endsection
@section('content')
    <link href="/lib/ueditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
    <script src="/js/mobileBUGFix.mini.js" type="text/javascript"></script>
    <link href="/css/ueditor.css" type="text/css" rel="stylesheet">
    <div class="content">
        <div class="header">
            <ul class="breadcrumb">
                <li><a href="/article/list">文章列表</a> </li>
                <li class="active">添加评论</li>
            </ul>
        </div>
        <div class="main-content">
            <ul class="nav nav-tabs nav-tabs-course">
                <li role="presentation" class="course_add active"><a href="javascript:void(0);">添加评论</a></li>
                <!-- <li role="presentation" class="course_hour_add"><a href="javascript:void(0);">课时添加</a></li> -->
            </ul>
            <form class="form-horizontal" id="courseFormInfo" action="/article/insertcomment" method="post">
                {{csrf_field()}}
                <div class="course_class row">
                    <div class="col-md-10">
                            <br>
                            <div class="tab-content">
                                
                                <div class="form-group">
                                    <label for="inputEmail3" class="col-sm-3 control-label">标题</label>
                                    <div class="col-sm-4">
                                        <input type="text" class="form-control" name="title" placeholder="信息名称" value="{{$article->title}}" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputPassword3" class="col-sm-3 control-label">封面图</label>
                                    <div class="col-sm-9">
                                        <img src="{{env('IMG_URL')}}{{$article->cover_url}}" id="cover_img" style="width:240px;max-height:240px;">
                                        
                                    </div>
                                </div>
                                
                                <div class="form-group">
                                    <label for="inputPassword3" class="col-sm-3 control-label">作者</label>
                                    <div class="col-sm-9">
                                        <button type="button" class="btn btn-primary btn-lg" data-page="1" onclick="selectAuthor(this);">选择</button>&nbsp;&nbsp;<span style="color:blue;" id="userName"></span>
                                        <input type="hidden" class="form-control" value="" id="inputPassword3" name="author">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="inputPassword3" class="col-sm-3 control-label">评论内容</label>
                                    <div class="col-sm-8">
                                        <textarea style="height:150px;" type="text/plain" class="form-control" placeholder="例如：课程精细讲解背部构造知识，让您拥有专属于自己的背部方案，练就姿态挺拔的强大气质" id="description" name="content"></textarea>
                                    </div>
                                </div>
                            </div>
                    </div>
                </div>
                <div class="row">
                    <input type="hidden" name="id" value="{{$article->id}}" />
                    <p>
                        <button type="submit" class="btn btn-primary col-md-offset-5" style="width:120px;background:#286090;color:#fff;">添加</button>
                    </p>
                </div>
            </form>
            <br/>
            <br/>    
        </div>
    </div>
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">选择作者</h4>
                </div>
                <div class="modal-body"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary">Save changes</button>
                </div>
            </div>
        </div>
    </div>
    <script src="/js/ueditor.js"></script>
    <script src="/js/course.js"></script>
    <script src="/lib/jquery.validate.js" type="text/javascript"></script>
    <script>
        
        $("#courseFormInfo").validate({
            onsubmit: true,// 是否在提交是验证
            submitHandler: function (form) {
                var author = $("input[name='author']").val();
                var description = $("#description").val();
                if(author == ''){
                    swal("请选择作者!");
                    return false;
                }
                if(description == ''){
                    swal('请填写评论');
                    return false;
                }
                
                form.submit();
            }
        });
    </script>
    <style type="text/css">
        .col-sm-2{
            width:60px;
        }
        .course_content{
            margin-right: -30px;
            margin-left: -30px;
            margin-top:5px;
        }
        .btn-success{
            background-image:none!important;
        }
    </style>
@endsection